package DemoFoodSystem;

import java.util.ArrayList;
import java.util.Scanner;

public class FoodOperator {
    private ArrayList<Food> foodlist=new ArrayList<>();
    Scanner sc=new Scanner(System.in);
    //foodlist=[]
    public void addFood(){
        Food f=new Food();
        System.out.println("请输入菜品名称：");
        String name=sc.next();
        f.setName(name);
        System.out.println("请输入菜品价格：");
        double price=sc.nextDouble();
        f.setPrice(price);
        System.out.println("请输入菜品月销量：");
        int sales=sc.nextInt();
        f.setSales(sales);
        foodlist.add(f);
    }
    public void showAllFood(){
        if(foodlist.size()==0){
            System.out.println("当前没有一个菜品！");
            return;
        }
        for (int i = 0; i < foodlist.size(); i++) {
            System.out.println(foodlist.get(i).getName());
            System.out.println(foodlist.get(i).getPrice());
            System.out.println(foodlist.get(i).getSales());
            System.out.println("-----------------");
        }
    }
    public void start(){
        exit:
        while (true) {
            System.out.println("====欢迎进入菜品系统====");
            System.out.println("1:添加菜品");
            System.out.println("2:展示全部菜品");
            System.out.println("请输入你的操作指令：");
            String command = sc.next();
            switch (command) {
                case "1":
                    addFood();
                    break;
                case "2":
                    showAllFood();
                    break;
                default:
                    System.out.println("没有该操作指令！");
                    continue exit;
            }
        }
    }
}
